﻿using System.Linq;
using MinecraftEnchantCalculator.Core;

namespace MinecraftEnchantCalculator.Models;

/// <summary>
///   附魔书类，继承自抽象附魔类<see cref="AbstractEnchant" />
///   专门用于表示可用于合并的附魔书物品，实现了附魔书特有的价值计算逻辑
/// </summary>
public class EnchantBook : AbstractEnchant
{
  /// <summary>
  ///   附魔书的附魔价值
  ///   计算方式：所有附魔的等级与对应附魔书乘数的乘积之和
  /// </summary>
  public override int Value => Enchantments.Sum(x => x.Level * x.BookMultiplier);

  /// <summary>
  ///   创建附魔书实例（工厂方法）
  ///   用于在合并操作时生成新的附魔书对象
  /// </summary>
  /// <returns>新的附魔书实例</returns>
  protected override AbstractEnchant CreateInstance()
  {
    return new EnchantBook();
  }
}